import java.io.*;
import java.net.*;

public class JavaClientUDP{
  
  public static void main(String[] args) throws IOException {
    
    final String SERVER = "aludra.usc.edu";
    final int PORT = 2000;

    //addr is of illegal length
    //InetAddress remoteHost = InetAddress.getByAddress("68.181.201.26".getBytes());
    InetAddress remoteHost = InetAddress.getByName(SERVER);
    DatagramSocket ds = new DatagramSocket();

    //Read Input from the User command line
    System.out.println("Enter Text :");
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    String userText = null;
    
    try{
	    userText = br.readLine();
	
    }catch(IOException e){
	     e.printStackTrace();
    }

    byte[] message = userText.getBytes();
    DatagramPacket dp = new DatagramPacket(message, message.length, remoteHost, PORT);
    ds.send(dp);
    
    System.out.println("Text sent to Server at : "+ SERVER + " on port # " + PORT );
	System.out.println("\n");
	ds.close();
	
  }

}